package gatperdut.chato.core.scores;

import gatperdut.chato.constants.CSConstantsScores;
import gatperdut.chato.model.Chato.Constant.Score;
import gatperdut.chato.model.Chato.Entity.Scores;

public class ScoresController {

    private final Scores scores;

    public ScoresController( Scores scores ) {
        this.scores = scores;
    }

    public Scores getScores() {
        return scores;
    }

    public String listScores() {
        StringBuilder sb = new StringBuilder();

        int i = 0;
        for ( Score sc : Score.values() ) {
            sb.append( CSConstantsScores.getScoreShortName( sc ) + " <" + getScore( sc ) + ">" );
            i++;
            if ( i < Score.values().length ) {
                sb.append( " " );
            }
        }

        return sb.toString();
    }

    public int getScore( Score score ) {
        switch ( score ) {
        case AGILITY:
            return getScores().getAgility();
        case CONSTITUTION:
            return getScores().getConstitution();
        case DEXTERITY:
            return getScores().getDexterity();
        case INTELLIGENCE:
            return getScores().getIntelligence();
        case POWER:
            return getScores().getPower();
        case STRENGTH:
            return getScores().getStrength();
        case WILLPOWER:
            return getScores().getWillpower();
        default:
            throw new IllegalArgumentException( "Retrieving value for unknown score." );
        }
    }

    public int getWeightCarry() {
        return CSConstantsScores.getWCarry( scores.getStrength() );
    }

}
